package com.sun.controller;

import com.sun.pojo.item;
import com.sun.pojo.item2;
import com.sun.service.itemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

@RestController
public class AJAXController {
    @Autowired
    itemService service;
    @RequestMapping("/query")
    public List<item> query(item2 item){
        return service.select(item);
    }

    @RequestMapping("/insert")
    public void insert(item item){
         service.insert(item);
    }
    @RequestMapping("/del")
    public String del(String id,String m){
        if (m.equals("051026")){
            service.del(Integer.parseInt(id));
            return "删除成功！";
        }else{
            return "密码错误！";
        }
    }
    @RequestMapping("/fix")
    public void fix(item item){
        System.out.println(item);
        service.fix(item);
    }
}
